package org.songwang.org.service.impl;

import org.songwang.basic.PageList;
import org.songwang.basic.query.BaseQuery;
import org.songwang.org.domain.Employee;
import org.songwang.org.mapper.IEmployeeMapper;
import org.songwang.org.query.EmployeeQuery;
import org.songwang.org.service.IEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service
@Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
public class EmployeeServiceImpl implements IEmployeeService {
    @Autowired
    private IEmployeeMapper employeeMapper;
    @Override
    public List<Employee> findAll() {
        return employeeMapper.findAll();
    }

    @Override
    public Employee findById(Long id) {
        return (Employee) employeeMapper.findById(id);
    }

    @Override
    @Transactional
    public void delete(Long id) {
        employeeMapper.delete(id);
    }

    @Override
    @Transactional
    public void add(Employee employee) {
        employeeMapper.add(employee);
    }

    @Override
    @Transactional
    public void update(Employee employee) {
        employeeMapper.update(employee);
    }

    @Override
    public PageList findQuery(BaseQuery query) {
        return null;
    }

    @Override
    public Long count(BaseQuery query) {
        return null;
    }

    @Override
    public PageList findQuery(EmployeeQuery query) {
        Long count = employeeMapper.count(query);
        List<Employee> query1 = employeeMapper.findQuery(query);
        return new PageList<>(count,query1);
    }

    @Override
    public Long count(EmployeeQuery query) {
        return employeeMapper.count(query);
    }
}
